local RoomLayer = class("RoomLayer",function()
    return cc.Layer:create()
end)

function RoomLayer.create()
    local layer = RoomLayer.new()
    layer:init( )
    return layer
end

function RoomLayer:ctor()

end

function RoomLayer:init()
    self.m_Json = ccs.GUIReader:getInstance():widgetFromJsonFile("image/ui/Json/LayerRoom.json")
    local WinSize = cc.Director:getInstance():getWinSize()
    self.m_Json:setScaleX(WinSize.width/self.m_Json:getContentSize().width)
    self.m_Json:setScaleY(WinSize.height/self.m_Json:getContentSize().height)
    self:addChild(self.m_Json)
    
    self.m_ImageViewjinbi = self.m_Json:getChildByName("lu_im_jinbi")
    
    self.m_BtnTitle = self.m_Json:getChildByName("u_bt_title")
    self.m_BtnTitle:setTitleText("游戏大厅")
    self.m_BtnTitle:setTouchEnabled(true)
    self.m_BtnTitle:addTouchEventListener(function(sender,eventType)self:onMenutClick(sender,eventType) end)
    
    self.m_BtnShop = self.m_Json:getChildByName("rd_bt_shop")
    self.m_BtnShop:setTouchEnabled(true)
    self.m_BtnShop:addTouchEventListener(function(sender,eventType)self:onMenutClick(sender,eventType) end)
    
    self.m_BtnActivity = self.m_Json:getChildByName("ld_bt_bisai")
    self.m_BtnActivity:setTouchEnabled(true)
    self.m_BtnActivity:addTouchEventListener(function(sender,eventType)self:onMenutClick(sender,eventType) end)
    
    self.m_BtnMenu = self.m_Json:getChildByName("ld_bt_caidan")
    self.m_BtnMenu:setTouchEnabled(true)
    self.m_BtnMenu:addTouchEventListener(function(sender,eventType)self:onMenutClick(sender,eventType) end)
    
    self.m_BtnGive = self.m_Json:getChildByName("rd_bt_bao")
    self.m_BtnGive:setTouchEnabled(true)
    self.m_BtnGive:addTouchEventListener(function(sender,eventType)self:onMenutClick(sender,eventType) end)
    
    self.m_BtnStart = self.m_Json:getChildByName("d_bt_star")
    self.m_BtnStart:setTouchEnabled(true)
    self.m_BtnStart:addTouchEventListener(function(sender,eventType)self:onMenutClick(sender,eventType) end)
    
    self.m_BtnSet = self.m_Json:getChildByName("ru_bt_set")
    self.m_BtnSet:setTouchEnabled(true)
    self.m_BtnSet:addTouchEventListener(function(sender,eventType)self:onMenutClick(sender,eventType) end)
    
    self.m_BtnKefu = self.m_Json:getChildByName("ru_bt_kefu")
    self.m_BtnKefu:setTouchEnabled(true)
    self.m_BtnKefu:addTouchEventListener(function(sender,eventType)self:onMenutClick(sender,eventType) end)
    
    self.m_BtnAward = self.m_Json:getChildByName("ru_bt_lingqu")
    self.m_BtnAward:setTouchEnabled(true)
    self.m_BtnAward:addTouchEventListener(function(sender,eventType)self:onMenutClick(sender,eventType) end)
    
    self.m_BtnPay = self.m_Json:getChildByName("ru_bt_pig")
    self.m_BtnPay:setTouchEnabled(true)
    self.m_BtnPay:addTouchEventListener(function(sender,eventType)self:onMenutClick(sender,eventType) end)
    
    self.m_ScrollView = self.m_Json:getChildByName("l_ScrollView")
 
    self.m_ImageViewBg = self.m_Json:getChildByName("cs_bg")
    self.m_Panel = self.m_Json:getChildByName("Plaza")
  
end


function RoomLayer:onMenutClick(sender,eventType)
    if eventType == ccui.TouchEventType.ended then
        if sender == self.m_BtnTitle then     
            print "=========RoomLayer:onMenutClick m_BtnTitle======================="
        elseif sender == self.m_BtnShop then     
            print "=========RoomLayer:onMenutClick m_BtnShop======================="
            require "view/Shop/ShopLayer".show()
        elseif sender == self.m_BtnActivity then     
            print "=========RoomLayer:onMenutClick m_BtnActivity======================="
            require "view/Activity/ActivityLayer".show()
        elseif sender == self.m_BtnMenu then     
            print "=========RoomLayer:onMenutClick m_BtnMenu======================="
        --    require "view/WaitMatch/WaitMatchLayer".show()
        --    require "view/WaitCheating/WaitCheatingLayer".show()
        --      require "view/UserWrap/UserWrapLayer".show()
        --    require "view/UserInfo/UserInfoLayer".show()
        --    require "view/Chat/ChatLayer".show()
        ---    require "view/Top/TopLayer".show()
         --   require "view/Bank/BankLayer".show()
            require "view/WaitNormal/WaitNormalLayer".show()
        elseif sender == self.m_BtnGive then     
            print "=========RoomLayer:onMenutClick m_BtnGive======================="
           
        elseif sender == self.m_BtnStart then     
            print "=========RoomLayer:onMenutClick m_BtnStart======================="
        elseif sender == self.m_BtnSet then     
            print "=========RoomLayer:onMenutClick m_BtnSet======================="
            require "view/Set/SetLayer".show()
        elseif sender == self.m_BtnKefu then     
            print "=========RoomLayer:onMenutClick m_BtnKefu======================="
            require "view/Service/ServiceLayer".show()
        elseif sender == self.m_BtnAward then     
            print "=========RoomLayer:onMenutClick m_BtnAward======================="
            require "view/Award/AwardLayer".show()
        elseif sender == self.m_BtnPay then     
            print "=========RoomLayer:onMenutClick m_BtnPay======================="
            
        end
    end
end
 
return RoomLayer